home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <signal.h>
- #ifdef SPASSWD
- #include <shadow.h>
- #endif
- #include <ctype.h>
- #include <sys/bsdtypes.h>
- #include <sys/types.h>
- #include <sys/stat.h>
-
-
- rename(s1, s2)
- char *s1, *s2;
- {
- char tmp[50];
- int i;
- unlink(s2);
- i = link(s1, s2);
- if(i == 0){
- /** unlink(s1); **/
- }
- return(i);
- }
-
- /* wait stuff */
-
- #define MAXZOMBIE 32
- struct zombie {
- int pid;
- int status;
- } zombie [MAXZOMBIE];
-
- int wait3 (statloc, options, dummy)
- int *statloc;
- int options;
- int *dummy; {
- int i, pid;
-
- do {
- for (i = 0; i < MAXZOMBIE; i++)
- if (zombie[i].pid) {
- if (statloc)
- *statloc = zombie[i].status;
- pid = zombie[i].pid;
- zombie[i].pid = 0;
- return pid;
- }
- } while (!options);
- return 0;
- }
-
- int
- sigchild_handler(sig, code)
- int sig;
- int code; {
- int victim, status, i;
- victim = wait (&status);
- signal (sig, sigchild_handler);
- for (i = 0; i < MAXZOMBIE; i++)
- if (!zombie[i].pid) {
- zombie[i].status = status;
- zombie[i].pid = victim;
- return;
- }
- }
-
- u_short swab(val)
- u_short val;
- {
- union swab
- {
- u_short val1;
- char chr[2];
- } swab1;
-
- char help;
-
- swab1.val1 = val;
- help = swab1.chr[1];
- swab1.chr[1] = swab1.chr[0];
- swab1.chr[0] = help;
-
- return (swab1.val1);
- }
-
- #ifdef SPASSWD
- /** /etc/shadow processing **/
-
- struct spwd *getspwdentry(name)
- char *name;
- {
-
- #define DEFAULTUSER "guest"
-
- FILE * fp;
- char *cp;
- char username[128];
- int fd;
- int uid;
- struct spwd *sw;
-
- /* Fix user name */
-
- for (cp = username; isalnum(uchar(*name)); *cp++ = tolower(uchar(*name++))) ;
- *cp = '\0';
- if (!isalpha(uchar(*username)) || strlen(username) > 8)
- strcpy(username, DEFAULTUSER);
-
- /* Search existing shadow entry */
-
- while ((sw = getspent()) && strcmp(username, sw->sp_namp)) ;
- endspent();
- if (sw) return sw;
- return 0;
- }
- #endif
-
- /* Some dummy functions */
-
- void
- abort()
- {
- exit();
- }
-
- rtprio()
- {
- }
-
- setresuid(uid, uid2, arg)
- int uid, uid2, arg;
- {
- }
-
- setresgid(gid, gid2, arg)
- int gid, gid2, arg;
- {
- }
-
- sigvector(sig, vec)
- int sig, vec;
- {
- signal(sig, SIG_IGN);
- }
-
- settimeofday()
- {
- }
-
-